// OGoMojo
// Whitemice.MOGI.MOGIMon
// License: LGPL
// Copyright: Whitemice Consulting, 2006
// Author(s): Adam Tauno Williams (awilliam@whitemice.org)
using System;
using System.Collections;

namespace Whitemice.MOGI.MOGIMon
{
	public enum ChangeType : uint { Update, Create, Delete };

	/// \brief Represents a change event
	public class Change
	{
		string		documentName;
		int			auditEntry;
		ChangeType	changeType;
		ArrayList	interestedParties;
	
		/// \brief Constructor
		/// \param auditEntry Audit entry this change is derived from
		/// \param documentName Document name of change object
		/// \param changeType Type of change
		public Change(int auditEntry, string documentName, ChangeType changeType)
		{
			this.documentName = documentName;
			this.auditEntry = auditEntry;
			this.changeType = changeType;
			interestedParties = new ArrayList();
		}
		
		/// \brief Add an interested party
		/// \param partyName MOGI document id of concerned account
		public void AddInterestedPary(string partyName)
		{
			interestedParties.Add(partyName);
		}
		
		/// \brief Is specified document a concerened object
		/// \param partyName MOGI document id to check for
		public bool IsInterested(string partyName)
		{
			return interestedParties.Contains(partyName);
		}
		
		/// \brief Return enumerator of interested parties collection
		public IEnumerator InterestedParties
		{
			get { return interestedParties.GetEnumerator(); }
		}
		
		/// \brief MOGI document name of changed object
		public string DocumentName
		{
			get { return documentName; }
		}
		
		/// \brief Id of audit entry
		public int AuditEntry
		{
			get { return auditEntry; }
			set { auditEntry = value; }
		}

		/// \bried Type of change		
		public ChangeType ChangeType
		{
			get { return changeType; }
			set { changeType = value; }
		}
	}
}